package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjseason;
import com.chezhujie.www.domain.vo.CzjseasonVO1;
import com.chezhujie.www.persistence.CzjseasonMapper;
import com.xy.core.page.Pagination;
import com.xy.core.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("CzjseasonService")
public class CzjseasonService {
	@Autowired
	private CzjseasonMapper czjseasonMapper;

	/**
	 * 查询某个czj_season  季节
	 * @param param
	 * @return
	 */
	public Czjseason getCzjseason(Map<String,Object> param) {
		return czjseasonMapper.getCzjseason(param);
	}
	
	/**
	 * 查询某个czj_season  季节
	 * @param param
	 * @return
	 */
	public CzjseasonVO1 getCzjseasonVO1(Map<String,Object> param) {
		return czjseasonMapper.getCzjseasonVO1(param);
	}	
	
	/**
	 * 查询某个czj_season  季节
	 * @param param
	 * @return
	 */
	public List<String> getCzjseasonALL() {
		return czjseasonMapper.getCzjseasonALL();
	}	
   
	/**
	 * 查询某个czj_season  季节queryImgOrder
	 * @param param
	 * @return
	 */
	public Czjseason queryImgOrder(Map<String,Object> param) {
		return czjseasonMapper.queryImgOrder(param);
	}	
	
	/**
	 * 查询czj_season  季节列表
	 * @return
	 */
	public Map<String,Object> getCzjseasonList(Map<String,Object> param) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("totalCounts", czjseasonMapper.getTotalRows(param));
		returnMap.put("list", czjseasonMapper.getCzjseasonList(param));
		return returnMap;
	}
   
	
	/**
	 * 查询czj_season  季节列表
	 * @return
	 */
	public  List<Czjseason> getCzjseasonListALL(Map<String,Object> param) {
		List<Czjseason> list=	czjseasonMapper.getCzjseasonListALL(param);
		return list;
		
	}	
	
	
	
	/**
	 * 查询czj_season  季节列表
	 * @return
	 */
	public Pagination getCzjseasonList(Map<String,Object> param, int pageSize, Integer pageNo, String order, String sort) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		p.setOrder(order);
		p.setSort(sort);
		param.putAll(p.toMap());
		int count=czjseasonMapper.getTotalRows(param);
		List<Czjseason> list=	czjseasonMapper.getCzjseasonList(param);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}
      
	/**
	 * 新增czj_season  季节
	 * @param czjseason
	 * @param param
	 */
	@Transactional
	public void insertCzjseason(Czjseason czjseason) {	
		czjseason.setSeasonId(UUIDUtils.getUUID());
		czjseasonMapper.insertCzjseason(czjseason);
	}
   
	/**
	 * 编辑czj_season  季节
	 * @param czjseason
	 * @param param
	 */
	@Transactional
	public void updateCzjseason(Czjseason czjseason) {
		czjseasonMapper.updateCzjseason(czjseason);
	}
   
	/**
	 * 删除czj_season  季节
	 * @param param
	 */    
	@Transactional
	public void deleteCzjseason(List<String> seasonIdList) {
		for(String seasonId: seasonIdList){
	  		Map<String,Object> param = new HashMap<String,Object>();
	  		param.put("seasonId", seasonId);
	 	   czjseasonMapper.deleteCzjseason(param);	  		
		}
	}


}